package com.imooc.trading_system.controller;


import com.imooc.trading_system.service.AddressService;
import com.imooc.trading_system.utils.JsonData;
import com.imooc.trading_system.vo.address.AddAddressReqVO;
import com.imooc.trading_system.vo.address.DeleteAddressReqVO;
import com.imooc.trading_system.vo.address.EditAddressReqVO;
import com.imooc.trading_system.vo.address.GetAddressByIdReqVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Feng zhaoxi
 * @since 2022-04-24
 */
@RestController
@RequestMapping("/api/address")
public class AddressController {
    @Autowired
    private AddressService addressService;

    /**
     * 新增地址
     *
     * @param addAddressReqVO
     * @return
     */
    @PostMapping("add_address")
    public JsonData addAddress(@RequestBody AddAddressReqVO addAddressReqVO) {
        return addressService.addAddress(addAddressReqVO);
    }

    /**
     * 编辑地址
     *
     * @param editAddressReqVO
     * @return
     */
    @PostMapping("edit_address")
    public JsonData editAddress(@RequestBody EditAddressReqVO editAddressReqVO) {
        return addressService.editAddress(editAddressReqVO);
    }

    /**
     * 删除地址
     *
     * @param deleteAddressReqVO
     * @return
     */
    @PostMapping("delete_address")
    public JsonData deleteAddress(@RequestBody DeleteAddressReqVO deleteAddressReqVO) {
        return addressService.deleteAddress(deleteAddressReqVO);
    }

    /**
     * 获取地址
     *
     * @return
     */
    @PostMapping("get_address_list")
    public JsonData getAddressList() {
        return addressService.getAddressList();
    }

    /**
     * 根据id获取地址详情
     *
     * @return
     */
    @PostMapping("get_address_by_id")
    public JsonData getAddressListById(@RequestBody GetAddressByIdReqVO getAddressByIdReqVO) {
        return addressService.getAddressListById(getAddressByIdReqVO);

    }
}

